# coding: utf-8

'''
    >>> d = D(a=1, b=2, c=3)
    >>> d.a
    1
    >>> d.x
    Traceback (most recent call last):
        ...
    AttributeError: 'D' object has no attribute 'x'

'''

class D(object):
    def __init__(self, **kwargs):
        self.__meu_atribs = kwargs
    def __getattr__(self, atrib):
        if atrib in self.__atribs:
            return self.__atribs[atrib]
        else:
            msg = "'%s' object has no attribute '%s'"
            classe = self.__class__.__name__
            raise AttributeError(msg % (classe, atrib))

if __name__=='__main__':
    import doctest
    doctest.testmod()
